package cn.asura.service.impl;

import cn.asura.mapper.BlogMapper;
import cn.asura.pojo.Blog;
import cn.asura.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Asura
 * @description
 * @createTime 2020-09-21 11:41
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class BlogServiceImpl implements BlogService {

    private BlogMapper blogMapper;

    @Autowired
    public void setBlogMapper(BlogMapper blogMapper) {
        this.blogMapper = blogMapper;
    }

    @Override
    public List<Blog> getBlogsByRule(String type) {
        return blogMapper.getBlogsByRule(type);
    }

    @Override
    public List<Blog> findByBlogTypeId(int blogTypeId) {
        return blogMapper.findByBlogTypeId(blogTypeId);
    }

    @Override
    public List<Blog> findAll(int id, String queryTitle, String blogTypeId, String startTime, String endTime) {
        return blogMapper.findAll(id, queryTitle, blogTypeId, startTime, endTime);
    }

    @Override
    public boolean create(Blog blog) {
        return blogMapper.create(blog) != 0;
    }

    @Override
    public Blog findByBlogId(int blogId) {
        return blogMapper.findByBlogId(blogId);
    }

    @Override
    public boolean update(Blog blog) {
        return blogMapper.update(blog) != 0;
    }

    @Override
    public boolean delete(int blogId) {
        return blogMapper.delete(blogId) != 0;
    }

    @Override
    public void addView(int blogId) {
        blogMapper.addView(blogId);
    }

}
